package com.tledu.cyrus.core;

/**
 * 封装统一给前端返回的结果
 *
 * @author cyrus
 */
public class AjaxResult<T> {
    private int code;
    private String msg;
    private T data;

    public static AjaxResult<Object> error(int code, String msg) {
        return new AjaxResult<Object>(code, msg, null);
    }

    public static AjaxResult<Object> error() {
        return error(500, "服务器内部异常，请联系管理员解决");
    }

    public static AjaxResult<Object> success(Object object) {
        return new AjaxResult<>(200, "请求成功", object);
    }

    public AjaxResult() {
    }

    public AjaxResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
